home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kmulticastsocketdevice.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  4.2 KB  |  152 lines

  1. /*  -*- C++ -*-
  2.  *  Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
  3.  *
  4.  *
  5.  *  Permission is hereby granted, free of charge, to any person obtaining
  6.  *  a copy of this software and associated documentation files (the
  7.  *  "Software"), to deal in the Software without restriction, including
  8.  *  without limitation the rights to use, copy, modify, merge, publish,
  9.  *  distribute, sublicense, and/or sell copies of the Software, and to
  10.  *  permit persons to whom the Software is furnished to do so, subject to
  11.  *  the following conditions:
  12.  *
  13.  *  The above copyright notice and this permission notice shall be included 
  14.  *  in all copies or substantial portions of the Software.
  15.  *
  16.  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17.  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18.  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19.  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20.  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21.  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22.  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  */
  24.  
  25. #ifndef KMULTICASTSOCKETDEVICE_H
  26. #define KMULTICASTSOCKETDEVICE_H
  27.  
  28. #include "ksocketdevice.h"
  29. #include "knetworkinterface.h"
  30. #include "ksocketaddress.h"
  31.  
  32. namespace KNetwork {
  33.  
  34. class KMulticastSocketImplPrivate;
  35.  
  36. /**
  37.  * @class KMulticastSocketImpl kmulticastsocketdevice.h kmulticastsocketdevice.h
  38.  * @brief The low-level backend for multicasting sockets.
  39.  *
  40.  * This class is an interface providing methods for handling multicast 
  41.  * operations.
  42.  *
  43.  * @author Thiago Macieira <thiago.macieira@kdemail.net>
  44.  */
  45. class KMulticastSocketImpl: public KSocketDevice
  46. {
  47. public:
  48.   /**
  49.    * Constructor.
  50.    */
  51.   KMulticastSocketImpl(const KSocketBase* = 0L);
  52.  
  53.   /**
  54.    * Destructor
  55.    */
  56.   virtual ~KMulticastSocketImpl();
  57.  
  58.   /**
  59.    * Sets our capabilities.
  60.    */
  61.   virtual int capabilities() const;
  62.  
  63.   /**
  64.    * Overrides the socket creation.
  65.    */
  66.   virtual bool create(int family, int type, int protocol);
  67.  
  68.   /**
  69.    * Overrides connection. Multicast sockets may not connect.
  70.    */
  71.   virtual bool connect(const KResolverEntry& address);
  72.  
  73.   /**
  74.    * Retrieves the time-to-live/hop count value on multicast packets being sent.
  75.    */
  76.   virtual int timeToLive() const;
  77.  
  78.   /**
  79.    * Sets the time-to-live/hop count for outgoing multicast packets.
  80.    *
  81.    * @param ttl        the hop count, from 0 to 255
  82.    * @returns true if setting the value was successful.
  83.    */
  84.   virtual bool setTimeToLive(int ttl);
  85.  
  86.   /**
  87.    * Retrieves the flag indicating if sent packets will be echoed back
  88.    * to sender.
  89.    */
  90.   virtual bool multicastLoop() const;
  91.  
  92.   /**
  93.    * Sets the flag indicating the loopback of packets to the sender.
  94.    *
  95.    * @param enable    if true, will echo back
  96.    * @returns true if setting the value was successful.
  97.    */
  98.   virtual bool setMulticastLoop(bool enable);
  99.  
  100.   /**
  101.    * Retrieves the network interface this socket is associated to.
  102.    */
  103.   virtual KNetworkInterface networkInterface();
  104.  
  105.   /**
  106.    * Sets the network interface on which this socket should work.
  107.    *
  108.    * @param iface    the interface to associate with
  109.    * @return true if setting the value was successful.
  110.    */
  111.   virtual bool setNetworkInterface(const KNetworkInterface& iface);
  112.  
  113.   /**
  114.    * Joins a multicast group. The group to be joined is identified by the 
  115.    * @p group parameter.
  116.    *
  117.    * @param group    the multicast group to join
  118.    * @returns true on success
  119.    */
  120.   virtual bool joinGroup(const KSocketAddress& group);
  121.  
  122.   /**
  123.    * @overload
  124.    * Joins a multicast group. This function also specifies the network interface
  125.    * to be used.
  126.    */
  127.   virtual bool joinGroup(const KSocketAddress& group, 
  128.              const KNetworkInterface& iface);
  129.  
  130.   /**
  131.    * Leaves a multicast group. The group being left is given by its address in the
  132.    * @p group parameter.
  133.    *
  134.    * @param group    the group to leave
  135.    * @returns true on successful leaving the group
  136.    */
  137.   virtual bool leaveGroup(const KSocketAddress& group);
  138.  
  139.   /**
  140.    * @overload
  141.    * Leaves a multicast group.
  142.    */
  143.   virtual bool leaveGroup(const KSocketAddress& group,
  144.               const KNetworkInterface& iface);
  145. private:
  146.   KMulticastSocketImplPrivate *d;
  147. };
  148.  
  149. }                // namespace KNetwork
  150.  
  151. #endif
  152.